

/*
-----------------------------------------------------------------------------
Filename:    OgreInitializeRenderer.cpp
Description: This is the OgreInterface implementation of the initializeRenderer method
specified in OgreInterface.h.
//-\|/-\|-\|/-\|-\|/-\|-\|/-\|-\|/-\|/-//
Sections occuring between two of these lines need to be restructured to accommodate access
from another GraphcisInterface function.
//-\|/-\|-\|/-\|-\|/-\|-\|/-\|-\|/-\|/-//
-----------------------------------------------------------------------------
*/


#include <Ogre.h>
#include <ode.h>

#include <assert.h>
#include "OgreInterface.h"
#include "ODEInterface.h"


using namespace Ogre;



OgreInterface::OgreInterface() { //empty constructor
}

/**
 *  initializeRenderer function for the Ogre Interface
 *
 *  windowLabel: A string input to determine the label of the window that the renderer uses.
 *  return: True for a successful initialization
 *          False if there was a cancelation/failure
 */
bool OgreInterface::initializeRenderer(char *windowLabel)
{
    //Create the root for the system
	root = new Root();

	//Display splash screen
	//true = user clicked "OK"
	//false = user clicked "Cancel"
	bool rtn = root->showConfigDialog();
	if(!rtn) {
	    return false;
	}

    //Startup the application & create a window, with argument provided as the label
    root->initialise(true, windowLabel);
    window = root->getAutoCreatedWindow();

    //Create a generic scene manager with the label defaultSM
    mSceneMgr = root->createSceneManager(ST_GENERIC, "defaultSM");

    //Use the manager to create a camera with the label MainCamera
    mainCam = mSceneMgr->createCamera("MainCamera");
    //Set up the camera's spatial positioning
    mainCam->setPosition(Vector3(0,0,500));
    mainCam->lookAt(Vector3(0,0,-300));
    //Setup the camera's clipping
    mainCam->setNearClipDistance(5);
    mainCam->setFarClipDistance(1000);

    //Attach a viewport to the window & set the BG color to white
    Viewport *vp = window->addViewport(mainCam);
    vp->setBackgroundColour(ColourValue( 1, 1, 1 ));


    return true;
}




